package world.criver.imagecompresstool.function;

import java.io.File;

public class funSize {
    public String numToStr(long size){
        double a=size;
        String end="B";
        if(a>1024){
            a/=1024;
            end="KB";
        }
        if(a>1024){
            a/=1024;
            end="MB";
        }
        if(a>1024){
            a/=1024;
            end="GB";
        }
        return String.format("%.2f %s",a,end);
    }
    public String countFileSize(File f){
        return numToStr(f.length());
    }
    public String countFileSize(String path){
        return numToStr(new File(path).length());
    }
}
